package cn.wiseda.finance.join;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;

public class PortfolioResultSetExtractor implements ResultSetExtractor {

//    public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
//        Portfolio portfolio = new Portfolio();
//        portfolio.setPortfolioId(rs.getInt(1));
//        portfolio.setPortfolioName(rs.getString(2));
//        List<Fund> list = portfolio.getFunds();
//        if (list == null) {
//            list = new ArrayList<Fund>();
//        }
//        Fund fund = new Fund();
//        fund.setFundId(rs.getInt(3));
//        fund.setName(rs.getString(4));
//        fund.setPrice(rs.getBigDecimal(5));
//        fund.setQuanity(rs.getInt(6));
//        list.add(fund);
//        portfolio.setFunds(list);
//        return portfolio;
//    }

    public Object extractData(ResultSet rs) throws SQLException {
        List<Portfolio> portfolioList = new ArrayList<Portfolio>();
        while (rs.next()) {
            Portfolio portfolio = new Portfolio();
            portfolio.setPortfolioId(rs.getInt(1));
            // rest of you processing here
        }
        return portfolioList;
    }

}